#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "message.h"


int main()
{
    int sock = 0;
    int client = 0;
    struct sockaddr_in saddr = {0};

    int len = 0;
    int r = 0;
    int i = 0;

    char buf[32] = {0}; // 数据缓冲区
    char input[32] = {0};

    Message* pm = Message_new(0 ,0 ,0 ,0 ,"A" ,1);

    sock = socket(PF_INET, SOCK_STREAM, 0);

    if( sock == -1 )
    {
        printf("socket error\n");
        return -1;
    }

    saddr.sin_family = AF_INET;
    saddr.sin_addr.s_addr = inet_addr("10.3.10.38");
    saddr.sin_port = htons(8899);

    if( connect(sock,(struct sockaddr*)&saddr,sizeof(saddr)) ==-1 )
    {
        printf("client connect error\n");
        return -1;
    }

    printf("client connect success!!!!\n");

    send(sock, pm ,sizeof(Message)+1,0);
    
    close(sock);
}